From: Jasper St. Pierre Date: Tue, 29 Oct 2013 20:13:32 +0000 (-0400) Subject: search: Always fetch the list of search providers X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~3146 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c0c20d49a5694aa78b359fefd5abe8c4d3dd0840;p=gnome-shell.git search: Always fetch the list of search providers We fetch and store the list of providers from the search system when we construct SearchResults, but we never update this list when providers are changed at runtime, causing various bugs making the search not seem as snappy as it should be. Make sure to always fetch the list of providers from the search system. --- diff --git a/js/ui/search.js b/js/ui/search.js index 1ee9471ed..466fb00ec 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -481,11 +481,9 @@ const SearchResults = new Lang.Class({ y_align: St.Align.MIDDLE }); this._content.add(this._statusBin, { expand: true }); this._statusBin.add_actor(this._statusText); - this._providers = this._searchSystem.getProviders(); - this._providerDisplays = {}; - for (let i = 0; i < this._providers.length; i++) { + this._searchSystem.getProviders().forEach(Lang.bind(this, function(provider) { this.createProviderDisplay(this._providers[i]); - } + })); this._highlightDefault = false; this._defaultResult = null; @@ -503,30 +501,26 @@ const SearchResults = new Lang.Class({ }, createProviderDisplay: function(provider) { - let providerDisplay = null; - - if (provider.appInfo) { + let providerDisplay; + if (provider.appInfo) providerDisplay = new ListSearchResults(provider); - } else { + else providerDisplay = new GridSearchResults(provider); - } providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn)); - this._providerDisplays[provider.id] = providerDisplay; this._content.add(providerDisplay.actor); + provider.display = providerDisplay; }, destroyProviderDisplay: function(provider) { - this._providerDisplays[provider.id].destroy(); - delete this._providerDisplays[provider.id]; + provider.display.destroy(); + provider.display = null; }, _clearDisplay: function() { - for (let i = 0; i < this._providers.length; i++) { - let provider = this._providers[i]; - let providerDisplay = this._providerDisplays[provider.id]; - providerDisplay.clear(); - } + this._searchSystem.getProviders().forEach(function(provider) { + provider.display.clear(); + }); }, reset: function() { @@ -545,9 +539,10 @@ const SearchResults = new Lang.Class({ _maybeSetInitialSelection: function() { let newDefaultResult = null; - for (let i = 0; i < this._providers.length; i++) { - let provider = this._providers[i]; - let display = this._providerDisplays[provider.id]; + let providers = this._searchSystem.getProviders(); + for (let i = 0; i < providers.length; i++) { + let provider = providers[i]; + let display = provider.display; if (!display.actor.visible) continue; @@ -570,16 +565,10 @@ const SearchResults = new Lang.Class({ }, _updateStatusText: function () { - let haveResults = false; - - for (let i = 0; i < this._providers.length; i++) { - let provider = this._providers[i]; - let display = this._providerDisplays[provider.id]; - if (display.getFirstResult()) { - haveResults = true; - break; - } - } + let haveResults = this._searchSystem.getProviders().some(function(provider) { + let display = provider.display; + return (display.getFirstResult() != null); + }); if (!haveResults) { this._statusText.set_text(_("No results.")); @@ -592,7 +581,7 @@ const SearchResults = new Lang.Class({ _updateResults: function(searchSystem, results) { let terms = searchSystem.getTerms(); let [provider, providerResults] = results; - let display = this._providerDisplays[provider.id]; + let display = provider.display; display.updateSearch(providerResults, terms, Lang.bind(this, function() { this._maybeSetInitialSelection();